package org.simalliance.openmobileapi;


import android.content.Context;

import java.util.concurrent.Executor;


public class SEService {

    android.se.omapi.SEService seService;
    SEService seService_;
    CallBack callBack;
    private Executor executor = new Executor() {
        @Override
        public void execute(Runnable r) {
            new Thread(r).start();
        }
    };


    public SEService(Context paramContext, CallBack paramCallBack) {

        ConnectedListener listener = new ConnectedListener();

        seService = new android.se.omapi.SEService(paramContext, executor, listener);
        callBack = paramCallBack;
    }

    public Reader[] getReaders() {

        android.se.omapi.Reader[] readers = seService.getReaders();

        Reader[] readers_ = new Reader[readers.length];

        for (int i = 0; i < readers.length; i++) {

            readers_[i] = new Reader(readers[i], seService_);
        }

        return readers_;


    }

    public String getVersion() {
        return seService.getVersion();
    }

    public boolean isConnected() {
        return seService.isConnected();
    }

    public void shutdown() {
        seService.shutdown();
    }

    public interface CallBack {

        void serviceConnected(SEService service);
    }

    class ConnectedListener implements android.se.omapi.SEService.OnConnectedListener {

        @Override
        public void onConnected() {
            callBack.serviceConnected(SEService.this);
        }
    }


}

